Skip to main content

parted

Introduction

This cheat sheet provides a quick reference for some common parted commands and concepts. parted is a command-line utility for partitioning and managing disk partitions on Unix-like operating systems.

parted Concepts

Displaying Disk Information

You can use parted to display information about your disks and partitions.

  • List available disks:

    parted --list
  • Select a specific disk for further operations:

    parted /dev/sdX

Partitioning Disks

parted allows you to create and manage partitions on disks.

  • Create a new partition:

    mkpart [filesystem-type] [start] [end]
  • Delete a partition:

    rm [partition-number]
  • Resize a partition:

    resize [partition-number] [end]
  • Set partition type (e.g., for EFI):

    set [partition-number] [type]

Working with File Systems

After creating partitions, you can create and manage file systems on them.

  • Create an ext4 file system:

    mkfs.ext4 /dev/sdX1
  • Mount a partition:

    mount /dev/sdX1 /mnt/mount-point
  • Unmount a partition:

    umount /mnt/mount-point

Labeling and Naming Partitions

You can assign labels and names to partitions for easier identification.

  • Set a label for an ext4 file system:

    e2label /dev/sdX1 mylabel
  • Set a name for a partition (GPT only):

    parted /dev/sdX name [partition-number] myname

parted Command-Line

  • List available disks:

    parted --list
  • Select a specific disk for further operations:

    parted /dev/sdX
  • Create a new partition:

    mkpart [filesystem-type] [start] [end]
  • Delete a partition:

    rm [partition-number]
  • Resize a partition:

    resize [partition-number] [end]
  • Set partition type (e.g., for EFI):

    set [partition-number] [type]
  • Create an ext4 file system:

    mkfs.ext4 /dev/sdX1
  • Mount a partition:

    mount /dev/sdX1 /mnt/mount-point
  • Unmount a partition:

    umount /mnt/mount-point
  • Set a label for an ext4 file system:

    e2label /dev/sdX1 mylabel
  • Set a name for a partition (GPT only):

    parted /dev/sdX name [partition-number] myname

Conclusion

This cheat sheet covers some common parted commands and concepts. parted is a useful tool for partitioning and managing disk partitions on Unix-like operating systems, making it essential for system administrators and storage management tasks; refer to the official parted documentation for more in-depth information and advanced usage.